{extend name="base"}
{block name="title"}
点赚金-后台管理-商品管理
{/block}
{block name="pageName"}
已审核商品列表
{/block}
{block name="css"}
	<style>
		.table th, .table td {
			text-align: center;
			vertical-align: middle!important;
		}
		#img_picture li,#Pics{
			display:inline-block;
			float:left;
		}
	</style>
	<script>
		function cleanPicInput(){
			$("#commodity_picture").val("");
			$("#img_picture").html("");
		}
	</script>
{/block}
{block name="pageBody"}
<!-- 一个表格 -->
<div class="btn-toolbar">
    <button class="btn btn-success" onclick="javascript:location.reload()">刷新</button>
  <div class="btn-group">
  </div>
</div>
<div class="well">
    <table class="table table-bordered" >
			<thead>
				<tr>
					<th>#</th>
					<th>商品名称</th>
					<th>商品图片</th>
					<th>分类</th>
					<th>商品价格</th>
					<th>发布时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="commoditys">
				{volist name='commoditys' id='commodity'}
				<tr id="{$commodity.commodity_id}">
					<th scope="row">{$i}</th>
					<td>{$commodity.commodity_name}</td>
					<td><img onclick="getPics('{$commodity.commodity_id}')" style="height: 150px" src="{$commodity.picture_address}"></td>
					<td>{$commodity.category_name}</td>
					<td>{$commodity.commodity_price} 元</td>
					<td>{$commodity.gmt_create}</td>
					<td>
						<button class="btn btn-primary dropdown-toggle" onclick="remove('{$commodity.commodity_id}')">撤销</button>
					</td>
				</tr>
				{/volist}	
			</tbody>
		</table>
</div>
<div class="pagination">
    {$commoditys->render()}
</div>

<script>
	function remove(commodity_id){
		if(confirm("确认审核不通过？")){
			$.getJSON("{:url('removeCommodity')}",{commodity_id:commodity_id},function(data){
				if(0 == data.code){
					$("#"+data.data).remove();
					alert("商品编号:"+data.data+"撤销成功");
				}else{
					alert("撤销失败");
				}
				
			});
		}
	}

	function getPics(commodity_id){
		$.getJSON("{:url('getCommodityPic')}",{commodity_id:commodity_id},function(data){
			$("#Pics").html("");
			if(0 == data.code){
				var pictures = data.data;
				for(var i=0;i<pictures.length;i++){
					$("#Pics").append("<li><img style='width:100px' src='"+pictures[i].picture_address+"'></li>");
				}
				$('#show_pic').modal('show');
			}else{
				alert("获取图片失败");
			}
		});
	}
</script>
{/block}

{block name="model"}
	<div id="show_pic" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel">商品图片</h3>
		</div>
	    <form class="form-horizontal">
	    	 <div class="control-group">
	            <div class="controls">
	              	 <ul id="Pics" >
	        		</ul>
	        	</div>
	        </div>
	    </form>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
		</div>
	</div>
{/block}